//
// Created by zhou on 2021/10/29.
//
#include <iostream>
#include <vector>
using namespace std;

class Solution {
public:
    int maxScoreSightseeingPair(vector<int>& values) {
        int size=values.size();
        if(size<2)return 0;
        int Score=(values[0]+values[1]-1);
        int maxScore=(values[0]+values[1]-1);
        for(int i=2;i<size;i++){
            Score=max(values[i]+values[i-1]-1,Score-values[i-1]+values[i]-1);
            maxScore=max(maxScore,Score);
        }
        return maxScore;
    }
};
int main(){
    vector<int> values={2,1,4,7,8,4,12};
    Solution solution;
    cout<<solution.maxScoreSightseeingPair(values);
}